package com.gsy.HW510;

public class AccountHolder {
    private double balance;
    private String user;


    //不想拆单例，将就着看
    public static AccountHolder createAccount(double balance,String user){
        return new AccountHolder(balance,user);
    }

    public boolean takeMoney(double money){
        if (money<0){
            return false;
        }
        if (this.balance - money < 50){
            return false;
        }
        this.balance -= money;
        return true;
    }
    public boolean saveMoney(double money){
        if (money<=0){
            return false;
        }
        this.balance += money;
        return true;
    }
    private AccountHolder(double balance, String user) {
        this.balance = balance;
        this.user = user;
    }

    public double getBalance() {
        return balance;
    }

    public void setBalance(double balance) {
        this.balance = balance;
    }

    public String getUser() {
        return user;
    }

    public void setUser(String user) {
        this.user = user;
    }
}
